package cn.fzm.demo01;

import cn.fzm.demo02.BookService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Dremeue
 * @create 2019-09-25 1:22
 **/
public class TestAnno {
    @Test
    public void testUserAdd() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        User user = (User) context.getBean("user");
        User user2 = (User) context.getBean("user");
        user.add();

        // 验证单例和多例模式
        System.out.println(user);
        System.out.println(user2);
    }

    @Test
    public void testBookService() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        BookService bookService = (BookService) context.getBean("bookService");
        bookService.add();
    }
}
